﻿using System;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using WindowsPhoneMVC.Navigation;
using WindowsPhoneMVC.Phone.Interfaces;

namespace WindowsPhoneMVC.Tests.Phone.Fakes
{
    public class FakeMvcFrame : IMvcFrame
    {
        private bool initialised;

        public void Show(PhoneApplicationPage view)
        {
            CurrentView = view;
        }

        public void ShowDialog(PhoneApplicationPage view)
        {
            CurrentView = view;
        }

        public void CloseDialog()
        {
        }

        public event EventHandler NavigationCanceled;

        public void OnNavigationCanceled(EventArgs e)
        {
            var handler = NavigationCanceled;
            if (handler != null) handler(this, e);
        }

        public void OnNavigationStarted(NavigationDirection direction)
        {
        }

        public void OnNavigationCompleted(bool successful)
        {
            
        }

        public bool IsAllowedToCancel { get; set; }

        public bool IsNavigationInProgress { get; set; }

        public bool IsGoBackButtonIntegrated { get; set; }

        public NavigationDirection NavigationDirection { get; set; }

        public bool IsContentEnabled { get; set; }

        public string LoadingMessage { get; set; }

        public PhoneApplicationPage CurrentView { get; set; }

        public void SetApplicationBar(IApplicationBar applicationBar)
        {
            
        }

        public void Initialise(IShell shell)
        {
            if (initialised)
                throw new InvalidOperationException("FakeMvcFrame should never be initialised twice");

            initialised = true;
        }

        public void UpdateOrientation(PhoneApplicationPage view)
        {
            
        }

        public void SetupSystemTray(PhoneApplicationPage page)
        {
            
        }

        public void BeginBackgroundOperation()
        {
        }

        public void EndBackgroundOperation()
        {
        }
    }
}
